Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
6b36bf79
Commit
6b36bf79
authored
Mar 16, 2005
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup debugging code and implement _dropBufferedAudio()
git-svn-id:
https://svn.musicpd.org/mpd/trunk@3090
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
b9bcfeaf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
32 deletions
+26
-32
audioOutput_osx.c
src/audioOutputs/audioOutput_osx.c
+26
-32
No files found.
src/audioOutputs/audioOutput_osx.c
View file @
6b36bf79
...
...
@@ -26,7 +26,7 @@
#include "../log.h"
#define BUFFER_SIZE
8192
#define BUFFER_SIZE
4096
typedef
struct
_OsxData
{
AudioUnit
au
;
...
...
@@ -98,32 +98,37 @@ static void osx_finishDriver(AudioOutput * audioOutput) {
}
static
void
osx_dropBufferedAudio
(
AudioOutput
*
audioOutput
)
{
/* not implemented yet */
OsxData
*
od
=
(
OsxData
*
)
audioOutput
->
data
;
pthread_mutex_lock
(
&
od
->
mutex
);
od
->
go
=
0
;
od
->
len
=
0
;
pthread_mutex_unlock
(
&
od
->
mutex
);
/*if(od->started) {
AudioOutputUnitStop(od->au);
od->started = 0;
}*/
}
static
void
osx_closeDevice
(
AudioOutput
*
audioOutput
)
{
OsxData
*
od
=
(
OsxData
*
)
audioOutput
->
data
;
DEBUG
(
"entering osx_closeDevice
\n
"
);
pthread_mutex_lock
(
&
od
->
mutex
);
od
->
go
=
0
;
while
(
od
->
len
)
{
DEBUG
(
"osx_closeDevice: cond_wait
\n
"
);
pthread_cond_wait
(
&
od
->
condition
,
&
od
->
mutex
);
}
pthread_mutex_unlock
(
&
od
->
mutex
);
DEBUG
(
"stopping au
\n
"
);
AudioOutputUnitStop
(
od
->
au
);
if
(
od
->
started
)
{
AudioOutputUnitStop
(
od
->
au
);
od
->
started
=
0
;
}
DEBUG
(
"closing au
\n
"
);
CloseComponent
(
od
->
au
);
AudioUnitUninitialize
(
od
->
au
);
DEBUG
(
"Leaving osx_closeDevice
\n
"
);
audioOutput
->
open
=
0
;
}
...
...
@@ -161,7 +166,6 @@ static OSStatus osx_render(void * vdata,
bytesToCopy
-=
bytes
;
}
assert
(
bytesToCopy
);
memcpy
(
buffer
->
mData
+
curpos
,
od
->
buffer
+
od
->
pos
,
bytesToCopy
);
od
->
pos
+=
bytesToCopy
;
curpos
+=
bytesToCopy
;
...
...
@@ -193,21 +197,17 @@ static int osx_openDevice(AudioOutput * audioOutput) {
desc
.
componentFlags
=
0
;
desc
.
componentFlagsMask
=
0
;
DEBUG
(
"finding component
\n
"
);
comp
=
FindNextComponent
(
NULL
,
&
desc
);
if
(
comp
==
0
)
{
ERROR
(
"Error finding OS X component
\n
"
);
return
-
1
;
}
DEBUG
(
"opening component
\n
"
);
if
(
OpenAComponent
(
comp
,
&
od
->
au
)
!=
noErr
)
{
ERROR
(
"Unable to open OS X component
\n
"
);
return
-
1
;
}
DEBUG
(
"initializing au
\n
"
);
if
(
AudioUnitInitialize
(
od
->
au
)
!=
0
)
{
CloseComponent
(
od
->
au
);
ERROR
(
"Unable to initialuze OS X audio unit
\n
"
);
...
...
@@ -217,7 +217,6 @@ static int osx_openDevice(AudioOutput * audioOutput) {
callback
.
inputProc
=
osx_render
;
callback
.
inputProcRefCon
=
od
;
DEBUG
(
"set callback
\n
"
);
if
(
AudioUnitSetProperty
(
od
->
au
,
kAudioUnitProperty_SetRenderCallback
,
kAudioUnitScope_Input
,
0
,
&
callback
,
sizeof
(
callback
))
!=
0
)
...
...
@@ -238,7 +237,6 @@ static int osx_openDevice(AudioOutput * audioOutput) {
streamDesc
.
mChannelsPerFrame
=
audioFormat
->
channels
;
streamDesc
.
mBitsPerChannel
=
audioFormat
->
bits
;
DEBUG
(
"set format
\n
"
);
if
(
AudioUnitSetProperty
(
od
->
au
,
kAudioUnitProperty_StreamFormat
,
kAudioUnitScope_Input
,
0
,
&
streamDesc
,
sizeof
(
streamDesc
))
!=
0
)
...
...
@@ -249,20 +247,11 @@ static int osx_openDevice(AudioOutput * audioOutput) {
return
-
1
;
}
DEBUG
(
"start
\n
"
);
int
err
=
AudioOutputUnitStart
(
od
->
au
);
if
(
err
)
{
ERROR
(
"unable to start audio output: %i
\n
"
,
err
);
return
-
1
;
}
od
->
go
=
1
;
od
->
pos
=
0
;
od
->
len
=
0
;
audioOutput
->
open
=
1
;
DEBUG
(
"opened OS X device
\n
"
);
return
0
;
}
...
...
@@ -271,6 +260,16 @@ static int osx_play(AudioOutput * audioOutput, char * playChunk, int size) {
int
bytesToCopy
;
int
curpos
;
if
(
!
od
->
started
)
{
od
->
go
=
1
;
od
->
started
=
1
;
int
err
=
AudioOutputUnitStart
(
od
->
au
);
if
(
err
)
{
ERROR
(
"unable to start audio output: %i
\n
"
,
err
);
return
-
1
;
}
}
pthread_mutex_lock
(
&
od
->
mutex
);
curpos
=
od
->
pos
+
od
->
len
;
...
...
@@ -278,10 +277,6 @@ static int osx_play(AudioOutput * audioOutput, char * playChunk, int size) {
while
(
size
)
{
while
(
od
->
len
>=
BUFFER_SIZE
)
{
if
(
curpos
!=
od
->
pos
)
{
DEBUG
(
"%i != %i
\n
"
,
curpos
,
od
->
pos
);
abort
();
}
pthread_cond_signal
(
&
od
->
condition
);
pthread_cond_wait
(
&
od
->
condition
,
&
od
->
mutex
);
}
...
...
@@ -299,7 +294,6 @@ static int osx_play(AudioOutput * audioOutput, char * playChunk, int size) {
bytesToCopy
-=
bytes
;
}
assert
(
bytesToCopy
);
memcpy
(
od
->
buffer
+
curpos
,
playChunk
,
bytesToCopy
);
curpos
+=
bytesToCopy
;
playChunk
+=
bytesToCopy
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment