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
87e06793
Commit
87e06793
authored
Jul 03, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of GetMacOSStatusCommentString
parent
8cc451a2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
7 deletions
+31
-7
OSXOutputPlugin.cxx
src/output/plugins/OSXOutputPlugin.cxx
+31
-7
No files found.
src/output/plugins/OSXOutputPlugin.cxx
View file @
87e06793
...
@@ -52,6 +52,20 @@ struct OSXOutput {
...
@@ -52,6 +52,20 @@ struct OSXOutput {
static
constexpr
Domain
osx_output_domain
(
"osx_output"
);
static
constexpr
Domain
osx_output_domain
(
"osx_output"
);
static
void
osx_os_status_to_cstring
(
OSStatus
status
,
char
*
str
,
size_t
size
)
{
CFErrorRef
cferr
=
CFErrorCreate
(
nullptr
,
kCFErrorDomainOSStatus
,
status
,
nullptr
);
CFStringRef
cfstr
=
CFErrorCopyDescription
(
cferr
);
if
(
!
CFStringGetCString
(
cfstr
,
str
,
size
,
kCFStringEncodingUTF8
))
{
/* conversion failed, return empty string */
*
str
=
'\0'
;
}
if
(
cferr
)
CFRelease
(
cferr
);
if
(
cfstr
)
CFRelease
(
cfstr
);
}
static
bool
static
bool
osx_output_test_default_device
(
void
)
osx_output_test_default_device
(
void
)
{
{
...
@@ -111,6 +125,7 @@ osx_output_set_device(OSXOutput *oo, Error &error)
...
@@ -111,6 +125,7 @@ osx_output_set_device(OSXOutput *oo, Error &error)
AudioDeviceID
*
deviceids
=
nullptr
;
AudioDeviceID
*
deviceids
=
nullptr
;
AudioObjectPropertyAddress
propaddr
;
AudioObjectPropertyAddress
propaddr
;
CFStringRef
cfname
=
nullptr
;
CFStringRef
cfname
=
nullptr
;
char
errormsg
[
1024
];
char
name
[
256
];
char
name
[
256
];
unsigned
int
i
;
unsigned
int
i
;
...
@@ -121,9 +136,10 @@ osx_output_set_device(OSXOutput *oo, Error &error)
...
@@ -121,9 +136,10 @@ osx_output_set_device(OSXOutput *oo, Error &error)
propaddr
=
{
kAudioHardwarePropertyDevices
,
kAudioObjectPropertyScopeGlobal
,
kAudioObjectPropertyElementMaster
};
propaddr
=
{
kAudioHardwarePropertyDevices
,
kAudioObjectPropertyScopeGlobal
,
kAudioObjectPropertyElementMaster
};
status
=
AudioObjectGetPropertyDataSize
(
kAudioObjectSystemObject
,
&
propaddr
,
0
,
nullptr
,
&
size
);
status
=
AudioObjectGetPropertyDataSize
(
kAudioObjectSystemObject
,
&
propaddr
,
0
,
nullptr
,
&
size
);
if
(
status
!=
noErr
)
{
if
(
status
!=
noErr
)
{
osx_os_status_to_cstring
(
status
,
errormsg
,
sizeof
(
errormsg
));
error
.
Format
(
osx_output_domain
,
status
,
error
.
Format
(
osx_output_domain
,
status
,
"Unable to determine number of OS X audio devices: %s"
,
"Unable to determine number of OS X audio devices: %s"
,
GetMacOSStatusCommentString
(
status
)
);
errormsg
);
ret
=
false
;
ret
=
false
;
goto
done
;
goto
done
;
}
}
...
@@ -133,9 +149,10 @@ osx_output_set_device(OSXOutput *oo, Error &error)
...
@@ -133,9 +149,10 @@ osx_output_set_device(OSXOutput *oo, Error &error)
deviceids
=
new
AudioDeviceID
[
numdevices
];
deviceids
=
new
AudioDeviceID
[
numdevices
];
status
=
AudioObjectGetPropertyData
(
kAudioObjectSystemObject
,
&
propaddr
,
0
,
nullptr
,
&
size
,
deviceids
);
status
=
AudioObjectGetPropertyData
(
kAudioObjectSystemObject
,
&
propaddr
,
0
,
nullptr
,
&
size
,
deviceids
);
if
(
status
!=
noErr
)
{
if
(
status
!=
noErr
)
{
osx_os_status_to_cstring
(
status
,
errormsg
,
sizeof
(
errormsg
));
error
.
Format
(
osx_output_domain
,
status
,
error
.
Format
(
osx_output_domain
,
status
,
"Unable to determine OS X audio device IDs: %s"
,
"Unable to determine OS X audio device IDs: %s"
,
GetMacOSStatusCommentString
(
status
)
);
errormsg
);
ret
=
false
;
ret
=
false
;
goto
done
;
goto
done
;
}
}
...
@@ -146,11 +163,12 @@ osx_output_set_device(OSXOutput *oo, Error &error)
...
@@ -146,11 +163,12 @@ osx_output_set_device(OSXOutput *oo, Error &error)
for
(
i
=
0
;
i
<
numdevices
;
i
++
)
{
for
(
i
=
0
;
i
<
numdevices
;
i
++
)
{
status
=
AudioObjectGetPropertyData
(
deviceids
[
i
],
&
propaddr
,
0
,
nullptr
,
&
size
,
&
cfname
);
status
=
AudioObjectGetPropertyData
(
deviceids
[
i
],
&
propaddr
,
0
,
nullptr
,
&
size
,
&
cfname
);
if
(
status
!=
noErr
)
{
if
(
status
!=
noErr
)
{
osx_os_status_to_cstring
(
status
,
errormsg
,
sizeof
(
errormsg
));
error
.
Format
(
osx_output_domain
,
status
,
error
.
Format
(
osx_output_domain
,
status
,
"Unable to determine OS X device name "
"Unable to determine OS X device name "
"(device %u): %s"
,
"(device %u): %s"
,
(
unsigned
int
)
deviceids
[
i
],
(
unsigned
int
)
deviceids
[
i
],
GetMacOSStatusCommentString
(
status
)
);
errormsg
);
ret
=
false
;
ret
=
false
;
goto
done
;
goto
done
;
}
}
...
@@ -183,9 +201,10 @@ osx_output_set_device(OSXOutput *oo, Error &error)
...
@@ -183,9 +201,10 @@ osx_output_set_device(OSXOutput *oo, Error &error)
&
(
deviceids
[
i
]),
&
(
deviceids
[
i
]),
sizeof
(
AudioDeviceID
));
sizeof
(
AudioDeviceID
));
if
(
status
!=
noErr
)
{
if
(
status
!=
noErr
)
{
osx_os_status_to_cstring
(
status
,
errormsg
,
sizeof
(
errormsg
));
error
.
Format
(
osx_output_domain
,
status
,
error
.
Format
(
osx_output_domain
,
status
,
"Unable to set OS X audio output device: %s"
,
"Unable to set OS X audio output device: %s"
,
GetMacOSStatusCommentString
(
status
)
);
errormsg
);
ret
=
false
;
ret
=
false
;
goto
done
;
goto
done
;
}
}
...
@@ -244,6 +263,7 @@ osx_render(void *vdata,
...
@@ -244,6 +263,7 @@ osx_render(void *vdata,
static
bool
static
bool
osx_output_enable
(
AudioOutput
*
ao
,
Error
&
error
)
osx_output_enable
(
AudioOutput
*
ao
,
Error
&
error
)
{
{
char
errormsg
[
1024
];
OSXOutput
*
oo
=
(
OSXOutput
*
)
ao
;
OSXOutput
*
oo
=
(
OSXOutput
*
)
ao
;
AudioComponentDescription
desc
;
AudioComponentDescription
desc
;
...
@@ -262,9 +282,10 @@ osx_output_enable(AudioOutput *ao, Error &error)
...
@@ -262,9 +282,10 @@ osx_output_enable(AudioOutput *ao, Error &error)
OSStatus
status
=
AudioComponentInstanceNew
(
comp
,
&
oo
->
au
);
OSStatus
status
=
AudioComponentInstanceNew
(
comp
,
&
oo
->
au
);
if
(
status
!=
noErr
)
{
if
(
status
!=
noErr
)
{
osx_os_status_to_cstring
(
status
,
errormsg
,
sizeof
(
errormsg
));
error
.
Format
(
osx_output_domain
,
status
,
error
.
Format
(
osx_output_domain
,
status
,
"Unable to open OS X component: %s"
,
"Unable to open OS X component: %s"
,
GetMacOSStatusCommentString
(
status
)
);
errormsg
);
return
false
;
return
false
;
}
}
...
@@ -324,6 +345,7 @@ static bool
...
@@ -324,6 +345,7 @@ static bool
osx_output_open
(
AudioOutput
*
ao
,
AudioFormat
&
audio_format
,
osx_output_open
(
AudioOutput
*
ao
,
AudioFormat
&
audio_format
,
Error
&
error
)
Error
&
error
)
{
{
char
errormsg
[
1024
];
OSXOutput
*
od
=
(
OSXOutput
*
)
ao
;
OSXOutput
*
od
=
(
OSXOutput
*
)
ao
;
AudioStreamBasicDescription
stream_description
;
AudioStreamBasicDescription
stream_description
;
...
@@ -371,9 +393,10 @@ osx_output_open(AudioOutput *ao, AudioFormat &audio_format,
...
@@ -371,9 +393,10 @@ osx_output_open(AudioOutput *ao, AudioFormat &audio_format,
status
=
AudioUnitInitialize
(
od
->
au
);
status
=
AudioUnitInitialize
(
od
->
au
);
if
(
status
!=
noErr
)
{
if
(
status
!=
noErr
)
{
osx_os_status_to_cstring
(
status
,
errormsg
,
sizeof
(
errormsg
));
error
.
Format
(
osx_output_domain
,
status
,
error
.
Format
(
osx_output_domain
,
status
,
"Unable to initialize OS X audio unit: %s"
,
"Unable to initialize OS X audio unit: %s"
,
GetMacOSStatusCommentString
(
status
)
);
errormsg
);
return
false
;
return
false
;
}
}
...
@@ -384,9 +407,10 @@ osx_output_open(AudioOutput *ao, AudioFormat &audio_format,
...
@@ -384,9 +407,10 @@ osx_output_open(AudioOutput *ao, AudioFormat &audio_format,
status
=
AudioOutputUnitStart
(
od
->
au
);
status
=
AudioOutputUnitStart
(
od
->
au
);
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
AudioUnitUninitialize
(
od
->
au
);
AudioUnitUninitialize
(
od
->
au
);
osx_os_status_to_cstring
(
status
,
errormsg
,
sizeof
(
errormsg
));
error
.
Format
(
osx_output_domain
,
status
,
error
.
Format
(
osx_output_domain
,
status
,
"unable to start audio output: %s"
,
"unable to start audio output: %s"
,
GetMacOSStatusCommentString
(
status
)
);
errormsg
);
return
false
;
return
false
;
}
}
...
...
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