Forum


Notice to all users

We are migrating towards a new forum system located at community.teamspeak.com, as such this forum will become read-only on January 29, 2020

Results 1 to 4 of 4
  1. #1
    Join Date
    May 2015
    Posts
    17

    How to use ts3client_acquireCustomPlaybackData?

    Hi everyone!

    Can anyone tell me how to use ts3client_acquireCustomPlaybackData correctly?
    I have created a custom device who already works great with the voice record and transferring but the sound gives me just always an error “2327”.

    In the Documentation the function should be used like this:

    Code:
    Retrieve playback data from the Client Lib:
    void ts3client_acquireCustomPlaybackData(	deviceID, 	 
     	buffer, 	 
     	samples);	 
    const char* deviceID;
    const short* buffer;
    int samples;
     
    •	deviceID
    ID string of the custom device. This is the ID under which the device was registered with ts3client_registerCustomDevice.
    •	buffer
    Buffer containing the playback data retrieved from the Client Lib.
    •	samples
    Size of the playback data buffer.
    Returns ERROR_ok if playback data is available or ERROR_sound_no_data if the Client Lib currently has no playback data.
    But that’s not correct, because in the example it is a “UINT”-type because of the given error-code.
    I use the function like that:

    Code:
                    audioPlay.Play();
                    short[] data = new short[(frequencyPLAY / 100) * 2];
                    bool running = true;
                    uint error = 0;
    
                    while (Play)
                    {
                        error = ts3_classes.ts3_client.ts3client_acquireCustomPlaybackData("MYDEVICE", data, (frequencyPLAY / 100) * 2);
                        if (error != ts3_classes.public_errors.ERROR_ok)
                        {
                            app_classes.global_data.command_and_event_log_public += "Error handling Sound DATA: " + error + "\n";
                            return;
                        }
    ...

    Can anyone tell me how to use ts3client_acquireCustomPlaybackData correctly please?

    Thank you everyone!

  2. #2
    Join Date
    May 2016
    Location
    Idar-Oberstein
    Posts
    163
    That function needs to be able to run in an OS'es audio callback, hence it doesn't block and wait until there's data for you and then return.
    If the client currently cannot give you the data you request, it'll return ERROR_sound_no_data and zero out the buffer.
    You'll simply want to pressure the client less hard (no while, run in a thread @10ms freq or such).
    Still, there can be occassions when this happens.
    You can use your error logging to see if there's a need for it.
    Your options there are "do nothing" or add a (e.g. circular) buffer, trading a slight delay for playback stability.
    It's not an error I'd publish to users, rather a return value, I'd not do logging on that on release versions for performance reasons if you're indeed using it in an OS'es audio callback - at least if the logging is synchronously.

  3. #3
    Join Date
    May 2015
    Posts
    17

    Solved

    Hi and thank you for your answer!

    I managed to make it work! For everyone who has the same issue here is my solution how to use it:

    First of all we have to include the needed functions like so:
    Code:
            [DllImport("libts3_sdk . so", EntryPoint = "ts3client_registerCustomDevice")]
            public static extern uint ts3client_registerCustomDevice(string Android, String Android_name, int fequenz_capture, int volume_capture, int frequenz_audio, int volume_audio);
    
            [DllImport("libts3_sdk . so", EntryPoint = "ts3client_openCaptureDevice")]
            public static extern uint ts3client_openCaptureDevice(uint64 serverConnectionHandlerID, string modeID, string captureDevice);
    
            [DllImport("libts3_sdk . so", EntryPoint = "ts3client_openPlaybackDevice")]
            public static extern uint ts3client_openPlaybackDevice(uint64 serverConnectionHandlerID, string modeID, string playbackDevice);
    
            [DllImport("libts3_sdk . so", EntryPoint = "ts3client_processCustomCaptureData")]
            public static extern uint ts3client_processCustomCaptureData(string empty, short[] bufferRec, int frequencyREC);
    
            [DllImport("libts3_sdk . so", EntryPoint = "ts3client_acquireCustomPlaybackData")]
            public static extern uint ts3client_acquireCustomPlaybackData(string Android, short[] bufferRec, int frequencyPLAY);
    
            [DllImport("libts3_sdk . so", EntryPoint = "ts3client_openCaptureDevice")]
            public static extern uint ts3client_openCaptureDevice(uint64 serverConnectionHandlerID, string modeID, string captureDevice);
    
            [DllImport("libts3_sdk . so", EntryPoint = "ts3client_openPlaybackDevice")]
            public static extern uint ts3client_openPlaybackDevice(uint64 serverConnectionHandlerID, string modeID, string playbackDevice);
    and use it like so:
    Code:
    error = ts3_client . ts3client_registerCustomDevice("MYDEVICE", “Client-name”, 48000, 1, 48000, 1);
                    if (error != ts3_classes . public_errors . ERROR_ok)
                    {
                        app_classes . global_data . command_and_event_log_public += "Error registering custom sound device: " + error + "\n";
                    }
    
    error = ts3_client . ts3client_openCaptureDevice(ts3_server_handler_id_public, "custom", "MYDEVICE");
                    if (error != ts3_classes . public_errors . ERROR_ok)
                    {
                        app_classes . global_data . command_and_event_log_public += "Error opening capture device: " + error + "\n";
                    }
    
                    /* Open default playback device */
                    /* Passing empty string for mode and NULL or empty string for device will open the default device */
                    error = ts3_client . ts3client_openPlaybackDevice(ts3_server_handler_id_public, "custom", "MYDEVICE");
                    if (error != ts3_classes . public_errors . ERROR_ok)
                    {
                        app_classes . global_data . command_and_event_log_public += "Error opening playback device: " + error + "\n";
                    }
    And I can play the data by SDK like so:

    Code:
    while (Play)
                    {
                    try
    
                    { 
    
                    error = ts3_classes . ts3_client . ts3client_acquireCustomPlaybackData("MYDEVICE", data, (frequencyPLAY / 100) * 2);
    
    
     --> MY CODE <--
                       
                    }
                    catch (Exception ex)
                    {
                        
                        //Audio play failed
                    }
    
                    Thread . Sleep(10);
                    }
    So it works great. Thank you for your help!
    The Thread can be closed!

  4. #4
    Join Date
    November 2016
    Posts
    1
    This is great. I like them very much
    Thank you very much. I will also introduce to my friends, hope you have a lot of good new and meaningful topics.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •